using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using student_factory.Metier;

namespace student_factory.AffectationEtudiant
{
    public partial class SelectionEtudiants : Form
    {
        private string idProjet;
        private string idProfil;
        private IList<string> identifiants;

        public SelectionEtudiants(string idProjet, string idProfil)
        {
            this.idProjet = idProjet;
            this.idProfil = idProfil;

            identifiants = new List<string>();

            InitializeComponent();
        }

        private void lst_etudiants_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void SelectionEtudiants_Load(object sender, EventArgs e)
        {
            IList<Etudiant> etudiants = DAO.EtudiantDAO.getNoProjetEtudiant(idProfil);

            foreach (Etudiant etu in etudiants)
            {
                lst_etudiants.Items.Add(etu.Etu_nom + " " + etu.Etu_prenom);
                identifiants.Add(etu.Id_e);
            }
        
        }

        private void bt_OK_Click(object sender, EventArgs e)
        {
            foreach (int indice in lst_etudiants.CheckedIndices)
            {
                DAO.EtudiantDAO.setProject(idProjet, identifiants[indice]);
            }
        }
    }
}